package com.example.springbootdemo.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.springbootdemo.entity.User;
import com.example.springbootdemo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImpl2 implements UserDao {
    @Autowired
    UserMapper userMapper;


    @Override
    public User registerUser(User user) {

        userMapper.insert(user);
        return user;
    }

    @Override
    public User searchUserByName(String username) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("customer_name", username);
        // 执行查询
        return userMapper.selectList(queryWrapper).get(0);
    }

    @Override
    public Boolean deleteUserById(Integer id) {
        return userMapper.deleteById(id) > 0;
    }
}
